<?php

/**
 * 
 * @author Administrator
 *
 */
class NoticeController extends ApiBaseController {

	/**
	 * 获取渠道最新的一条公告
	 */
    public function getLastNotice(){  	
    	
    	$channel_id = PubRequest::R('channel_id');
    	$type = PubRequest::R('type');
    	if(!isset($channel_id)){
    		$json_arr = array('status'=>-1,'msg'=>'缺少参数channel_id','data'=>'' );
    		ApiBaseService::doLog($_POST, $json_arr);
			exit(json_encode($json_arr));
    	}
    	
    	if($type =='' && $type != 1 && $type != 2){
    		$type = 1;
    	}

    	$modNoticeSet = new ModNoticeSet();
    	$result = $modNoticeSet->lastOne($channel_id,$type);
    	

    	if(!$result['status']){
    		$json_arr = array('status'=>-1,'msg'=>$result['msg'],'data'=>'' );
    		ApiBaseService::doLog($_POST, $json_arr);
    		exit(json_encode($json_arr));
    	}else{
    		$data = $result['data'];
    		$content = '';
    		$content = $data[0]['content'];
    		$is_eject = $data[0]['is_eject'];
    		$notice_id = $data[0]['id'];
    		$data = array('content'=>$content,'is_eject'=>$is_eject,'notice_id'=>$notice_id);
    		$json_arr = array('status'=>200,'msg'=>'查询成功','data'=>$data );
    		ApiBaseService::doLog($_POST, $json_arr);
    		exit(json_encode($json_arr));
    	}
    	
    }
    
    
   

}